package com.qupai.controller.auction;


import com.qupai.domain.dto.AuctionDTO;
import com.qupai.domain.entity.Auction;
import com.qupai.domain.result.Result;
import com.qupai.domain.vo.AuctionDetailVO;
import com.qupai.domain.vo.AuctionEndVO;
import com.qupai.domain.vo.AuctionVO;
import com.qupai.service.IAuctionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 拍卖表，存储拍卖活动信息 前端控制器
 * </p>
 *
 * @author bluefoxyu
 * @since 2024-07-30
 */
@RestController
@RequestMapping("/auction/auction")
@Tag(name = "志愿-拍卖会相关接口")
public class AuctionController {

    @Resource
    private IAuctionService auctionService;

    @Operation(summary = "举办拍卖会")
    @PostMapping("/hold")
    public Result<Auction> hold(@RequestBody AuctionDTO auctionDTO){
        return Result.success(auctionService.hold(auctionDTO));
    }

    @Operation(summary = "修改拍卖会信息")
    @PutMapping("/update")
    public Result<Auction> update(@RequestBody AuctionDTO auctionDTO){
        return Result.success(auctionService.updateAuction(auctionDTO));
    }


    @Operation(summary = "查询自己举办的拍卖会")
    @GetMapping("/find")
    public Result<List<AuctionVO>> find(AuctionDTO auctionDTO){
        return Result.success(auctionService.find(auctionDTO));
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据拍卖会id查详细信息")
    public Result<AuctionDetailVO> detail(@PathVariable Long id)
    {
        return Result.success(auctionService.detail(id));
    }

}
